home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / incl / LEDA / h_array.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.5 KB  |  59 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  h_array.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_H_ARRAY_H
  16. #define LEDA_H_ARRAY_H
  17.  
  18. //------------------------------------------------------------------------------
  19. // h_array  
  20. //------------------------------------------------------------------------------ 
  21. #include <LEDA/basic.h> 
  22. #include <LEDA/impl/ch_array.h> 
  23.  
  24.  
  25. template<class itype, class etype>
  26.  
  27. class _CLASSTYPE h_array : private ch_array {
  28.  
  29.  void copy_inf(GenPtr& x)    const { x=Copy(ACCESS(etype,x));  }
  30.  void clear_inf(GenPtr& x)   const { Clear(ACCESS(etype,x)); }
  31.  
  32.  public:
  33.  
  34.  etype& operator[](itype y) { return ACCESS(etype,access(Convert(y))); }
  35.  
  36.  etype operator[](itype y) const { return ACCESS(etype,access(Convert(y))); }
  37.  
  38.  bool defined(itype y) const { return (lookup(Convert(y)) != nil); }
  39.  
  40.  
  41.  void start_iteration()  { }
  42.  bool next_index(itype&) { return false; }
  43.  
  44.  h_array() {}
  45.  h_array(etype i) : ch_array(Copy(i),sizeof(itype)) {}
  46.  h_array(etype i, int sz) : ch_array(Copy(i),sz) {}
  47.  h_array(etype i, int sz, int n) : ch_array(Copy(i),sz,n) {}
  48.  h_array(const h_array<itype,etype>& A): ch_array((ch_array&)A) {}
  49. ~h_array() { }
  50.  
  51. };
  52.  
  53.  
  54. #define forall_defined(i,A)  for ((A).start_iteration(); (A).next_index(i); )
  55.  
  56.  
  57. #endif
  58.